<template>
    <div>
        <i class="preview_bn_fix" v-if="isShow"></i>
        <component class="bn-container p-t-20 p-b-20" :config="configFilter" :is="name" :isEdit="isEdit" @update="update" @loadSuccess="loadSuccess"></component>
    </div>
</template> 

<script>
// 这是所有模板与简历的聚合组件，所有的模板都必须在这个注册
export default {
    components: {
        classicStyleOne: () =>
            import('@/views/biographical_notes/components/preview_bn/classicStyleOne/index.vue'),
    },
    props: {
        name: {
            type: String,
            default: '',
        },
        isEdit: {
            type: Boolean,
            default: false,
        },
        config: {
            type: Object,
            default: () => {
                return {}
            },
        },
    },
    data() {
        return {
            loadSuccessArrCode:[]
        }
    },
    computed:{
        configFilter(){
            // 有些组件可以设置不显示，需要过滤掉
            let result = this.deepCopy(this.config)
            result.list = this.config.list.filter(item=>{
                return item.is_show != 2
            })
            return result
        },
        isShow(){
            return this.config.list.every(({row_code,is_show})=>{
                // console.log('is_show',is_show,this.loadSuccessArrCode,row_code);
                
                return is_show == 2 || this.loadSuccessArrCode.includes(row_code)
            })
        }
    },
    methods: {
        update(row) {
            this.$emit('update', row)
        },
        loadSuccess(row){
            this.loadSuccessArrCode.push(row.row_code)
            
        }
    },
}
</script>
